home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / intchart.tqt / intchart.txt
Text File  |  1985-06-27  |  26KB  |  615 lines

  1.                        HOW TO USE THE ROM BIOS INTERRUPTS
  2.                                  by Scott Pakin
  3.  
  4.  
  5. Introductory Notes:
  6.  
  7. 1) It is assumed that the reader knows a little bit of assembly language
  8.    programming.
  9.  
  10. 2) These charts were taken from the ROM BIOS listing in the Technical
  11.    Reference Manual.
  12.  
  13. 3) All interrupts and function numbers are given in HEXADECIMAL (base 16)!!!
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26. SEND ALL QUESTIONS AND COMMENTS TO:
  27. Scott Pakin
  28. 6007 N. Sheridan Rd.
  29. Chicago, IL    60660
  30.  
  31.  
  32. INTERRUPT 10 -- Display (VIDEO) I/O
  33.  
  34. (AH)    Operation            Also on entry              On return
  35. ------------------------------------------------------------------------------
  36.  
  37.   0     Set video mode       (AL) = 0  40x25 B/W         
  38.                                   = 1  40x25 Color
  39.                                   = 2  80x25 B/W
  40.                                   = 3  80x25 Color
  41.  
  42.                                   = 4  320x200 Color
  43.                                   = 5  320x200 B/W
  44.                                   = 6  640x200 B/W
  45.  
  46.   1     Set cursor type      CH bits 0-4 = Start line    
  47.                              CL bits 0-4 = End line
  48.  
  49.                              [Other bits must be zero
  50.                              or problems may occur]
  51.  
  52.   2     Position cursor      (DH,DL) = Row, Column       
  53.                              (BH) = Page number
  54.  
  55.   3     Read cursor pos.     (BH) = Page number         (DH,DL) = Row, Column
  56.                                                         (CH,CL) = Cursor type
  57.  
  58.   4     Read light pen pos.                             (AH) = 1
  59.                                                         (DH,DL) = Row, Column
  60.                                                                   for characters
  61.                                                         (CH,BX) = Row, Column
  62.                                                                   for pixels
  63.  
  64.                                                         [ If (AH) = 0, then
  65.                                                         the light pen switch
  66.                                                         is not down/triggered]
  67.  
  68.   5     Select display page  (AL) = New page value       
  69.         [ Valid only in
  70.         text modes. ]        [ (AL) must be 0-7 for
  71.                              40-column and 0-3 for
  72.                              80-column modes.]
  73.  
  74.   6     Scroll page up       (AL) = No. of lines
  75.                              (CH,CL) = Upper left (R,C)
  76.                              (DH,DL) = Lower right (R,C)
  77.                              (BH) = Attribute to be used
  78.                                     on bottom lines
  79.  
  80.                              [ (AL) = 0 clears entire
  81.                              screen. ]
  82.  
  83.  
  84. INTERRUPT 10 -- Display (VIDEO) I/O
  85.  
  86. (AH)    Operation            Also on entry              On return
  87. ------------------------------------------------------------------------------
  88.  
  89.   7     Scroll page down     Same as function #6         
  90.                              except (BH) is the
  91.                              attribute to be used
  92.                              on the bottom lines
  93.  
  94.   8     Read attribute/      (BH) = Display page        (AL) = Character read
  95.         character at current                            (AH) = Attribute
  96.         cursor position
  97.                                                         [ (AH) is invalid if in
  98.                                                         in graphics modes. ]
  99.  
  100.   9     Write attribute/     (BH) = Display page
  101.         character at current (BL) = Attribute (Text)
  102.         cursor position           = Char. color (Graphics)
  103.                              (CX) = No. of chars. to write
  104.                              (AL) = Char. to write
  105.  
  106.   A     Write character      (BH) = Display page
  107.         only at current      (CX) = No. of characters to
  108.         cursor position             write
  109.                              (AL) = Character to write
  110.  
  111.   B     Set color palette    (BH) = Palette color ID (0-127)
  112.                              (BL) = Color value to be used
  113.                                     with the color ID
  114.  
  115.   C     Write dot            (DX,CX) = Row, Column
  116.                              (AL) = Color
  117.  
  118.                              [ If (AH) > 127, the dot will
  119.                              be exclusive-or'd with the dot
  120.                              presently occupying the dot
  121.                              position. ]
  122.  
  123.   D     Read dot             (DX,CX) = Row, Column      (AL) = Color of dot read
  124.  
  125.  
  126.   E     Teletype output      (AL) = Character to write
  127.                              (BL) = Foreground color
  128.                              (BH) = Display page
  129.  
  130.                              [ (BL) is only valid in
  131.                              text modes. ]
  132.  
  133.  
  134. INTERRUPT 10 -- Display (VIDEO) I/O
  135.  
  136. (AH)    Operation            Also on entry              On return
  137. ------------------------------------------------------------------------------
  138.  
  139.   F     Read video mode                                 (AL) = 0  40x25 B/W
  140.                                                              = 1  40x25 Color
  141.                                                              = 2  80x25 B/W
  142.                                                              = 3  80x25 Color
  143.  
  144.                                                              = 4  320x200 Color
  145.                                                              = 5  320x200 B/W
  146.                                                              = 6  640x200 B/W
  147.  
  148.                                                              = 7  Monochrome
  149.  
  150.                                                         (AH) = No. of char.
  151.                                                                columns on screen
  152.  
  153.                                                         (BH) = Current display
  154.                                                                page
  155. ________________________________________________________________________________
  156.  
  157. Notes on interrupt 10:
  158.  
  159. 1) Page numbers are invalid in graphics modes or when using the monochrome
  160.    monitor. If a register requires a page number, set it to zero if it's
  161.    invalid.
  162.  
  163. 2) For (Row, Column), (0,0) is upper left.
  164.  
  165. 3) Text modes are often called Alphanumeric (Alpha) modes; there is no
  166.    difference between the two.
  167.  
  168. 4)              Palette 0               Palette 1
  169.             -------------------------------------
  170.    Color 1  |   Green                   Cyan
  171.    Color 2  |   Red                     Magenta
  172.    Color 3  |   Brown/Yellow            Grey/White
  173.  
  174.         [ Color 3 is dependant on the background color. ]
  175.  
  176.         Background Colors
  177.    Color        (dec.)  (bin.)
  178.  
  179.    Black           0    0000
  180.    Blue            1    0001
  181.    Green           2    0010
  182.    Cyan            3    0011
  183.    Red             4    0100
  184.    Magenta         5    0101
  185.    Brown           6    0110
  186.    Light Grey      7    0111
  187.    Dark Gray       8    1000
  188.    Light Blue      9    1001
  189.    Light Green    10    1010
  190.    Light Cyan     11    1011
  191.    Light Red      12    1100
  192.    Light Magenta  13    1101
  193.    Yellow         14    1110
  194.    White          15    1111
  195.  
  196.  
  197. INTERRUPT 13 -- Diskette I/O
  198.  
  199. (AH)    Operation            Also on entry              On return
  200. ------------------------------------------------------------------------------
  201.  
  202.   0     Reset diskette
  203.         system
  204.  
  205.   1     Read diskette status                            (AL) = Diskette status
  206.  
  207.                                                         [ See note #1 for a
  208.                                                         diagram of this byte. ]
  209.  
  210.   2     Read sectors into    (AL) = Number of sectors   Carry flag = 0
  211.         a buffer             (CL) = Starting sector #          (AL) = No. of
  212.                              (CH) = Track number (0-39)        sectors read
  213.                              (DL) = Drive number           [ If CF is 1, then
  214.                                     (0=A, 1=B, 2=C, 3=D)   the operation was
  215.                              (DH) = Head number (0 or 1)   unsuccessful and
  216.                              (ES:BX) = Address of buffer   (AH) = Diskette
  217.                                                                   status ]
  218.  
  219.   3     Write sectors from   Same as function #2        Same as function #2
  220.         a buffer
  221.  
  222.   4     Verify sectors      Same as function #2, but    Same as function #2
  223.                              the buffer is not needed
  224.  
  225.   5     Format a track      (ES:BX) = Sector information   (AL) does not return
  226.                             (DL) = Drive #                 any informatiom,
  227.                             (AL) = # of sectors to format  otherwise, results
  228.                                                            are the same as in
  229.                             [ see note #2 for more         function #2
  230.                             information ]
  231.  
  232. ________________________________________________________________________________
  233.  
  234. Notes on interrupt 13:
  235.  
  236. 1) The diskette staus byte looks like this:
  237.  
  238.         7 6 5 4 3 2 1 0         Bits 0 & 1 -- if 01, invalid command
  239.                                               if 10, address mark (to locate
  240.                                                      sectors) was not found
  241.                                               if 11, write protect prevented
  242.                                                      writing on disk
  243.  
  244.                                 Bit     Meaning (if on)
  245.                                  2      Sector not found
  246.                                  3      Direct memory access overrun, or
  247.                                         if bit 0 is on (1), illegal attempt to
  248.                                         transfer data across a 64K boundry
  249.                                  4      Cyclical redundancy check detected a
  250.                                         read error
  251.                                  5      Diskette controller chip returned an
  252.                                         error
  253.                                  6      Seek operation to a track failed
  254.                                  7      Drive failed to respond (time-out error)
  255.  
  256.  
  257. 2) The formatting data in the extra segment is set up like this:
  258.  
  259.         Byte number     Meaning
  260.             1           Track number (0-39)
  261.             2           Head number (0 or 1)
  262.             3           Sector number (1-8; 9 if DOS 2.xx)
  263.             4           Number of bytes for sector
  264.                         (0=128, 1=256, 2=512, 3=1024)
  265.  
  266.    Only full tracks may be formatted;  not individual sectors.  This means that
  267.    the above data must appear eight (nine for DOS 2.00+) times -- 32 bytes total
  268.    for an entire track.  Remember to set (AL) to match the number of sectors to
  269.    be formatted.
  270.  
  271.  
  272. INTERRUPT 14 -- Asyncronous Communications (RS-232) I/O
  273.  
  274. (AH)    Operation            Also on entry              On return
  275. ------------------------------------------------------------------------------
  276.  
  277.   0     Initialize           (DX) = Communications      (AX) = Status word
  278.         communications port         adapter (0 = COM1,
  279.                                     1 = COM2)           [ See note #2 for more
  280.                                                         information ]
  281.                              (AL) = Parameters for
  282.                                     initialization
  283.  
  284.                              [ See note #1 for more
  285.                              information ]
  286.  
  287.   1     Send a character     (DX) = Communications      If (AH) > 127, an error
  288.         over the comm. line         adapter             occurred; low 15 bits of
  289.                              (AL) = Character to send   (AX) have status word
  290.  
  291.   2     Wait for character   (DX) = Communications      If (AH) is non-zero, an
  292.         from comm. line             adapter             error occurred; (AX) has
  293.                                                         status word
  294.  
  295.   3     Read status word                                (AX) = Status word
  296.  
  297.                                                         [ See note #2 for more
  298.                                                         information ]
  299. ________________________________________________________________________________
  300.  
  301. Notes on interrupt 14:
  302.  
  303. 1) The parameters for initializing the communications adapter are as follows:
  304.  
  305.         7 6 5 4 3 2 1 0         Bits 0 & 1 =  Word length; 10 = 7 bit bytes
  306.                                                            11 = 8 bit bytes
  307.  
  308.                                 Bit 2      =  Stopbits;     0 = 1 stopbit
  309.                                                             1 = 2 stopbits
  310.  
  311.                                 Bits 3 & 4 =  Parity;      x0 = no parity
  312.                                                            01 = odd parity
  313.                                                            11 = even parity
  314.  
  315.                                                            [x could be 1 or 0 ]
  316.  
  317.                                 Bits 5-7   =  Speed;       000 =  110 bps
  318.                                                            001 =  150 bps
  319.                                                            010 =  300 bps
  320.                                                            011 =  600 bps
  321.                                                            100 = 1200 bps
  322.                                                            101 = 2400 bps
  323.                                                            110 = 4800 bps
  324.                                                            111 = 9600 bps
  325.  
  326.  
  327. 2) The communications port status is returned in (AX):
  328.  
  329.         15 14 13 12 11 10 09 08      07 06 05 04 03 02 01 00
  330.         (AH) = Line control status   (AL) = MODEM status
  331.  
  332.        Bit      Meaning (when on)
  333.          0      Delta clear-to-send
  334.          1      Delta data set ready
  335.          2      Trailing edge ring detected
  336.          3      Delta receive line signal detected
  337.          4      Clear-to-send signal
  338.          5      Data set (MODEM) ready
  339.          6      Ring indication
  340.          7      Line signal detected
  341.  
  342.          8      Data ready
  343.          9      Overrun error
  344.         10      Parity error
  345.         11      Framing error
  346.         12      Break detected
  347.         13      Transmission holding-register empty
  348.         14      Transmission shift-register empty
  349.         15      Time out
  350.  
  351.         [ NOTE: Bits 15, 10, and 8 might be set incorrectly if you have a
  352.         BIOS with a release date of 4/24/81 ]
  353.  
  354.  
  355. INTERRUPT 15 -- Cassete I/O
  356.  
  357. (AH)    Operation            Also on entry              On return
  358. ------------------------------------------------------------------------------
  359.  
  360.   0     Turn cassette motor on
  361.  
  362.   1     Turn cassette motor off
  363.  
  364.   2     Read one or more     (CX) = Number of bytes     (DX) = Number of bytes
  365.         256-byte blocks from        to read                    read
  366.         cassette into a      (ES:BX) = Pointer to       Carry flag = 0 if
  367.         buffer                        buffer            successful
  368.                                                         If unsuccessful, the
  369.                                                         carry flag = 1 and (AH)
  370.                                                         has the error code
  371.  
  372.                                                         [ See note #1 for more
  373.                                                         information ]
  374.  
  375.   3     Write one or more    (CX) = Number of bytes     (CX) = 0
  376.         256-byte blocks from        to write            (ES:BX) = Pointer to the
  377.         a buffer to          (ES:BX) = Pointer to buffer          byte after the
  378.         cassette                                                  last byte
  379.                                                                   written
  380. ________________________________________________________________________________
  381.  
  382. Notes on interrupt 15:
  383.  
  384. 1) Error returns for function #2:
  385.  
  386.         7 6 5 4 3 2 1 0
  387.  
  388.          Bit    Meaning (when on)
  389.           0     Cyclical redundancy check failed
  390.           1     Data transactions were lost
  391.           2     No data was found
  392.  
  393.     All other bits have no purpose
  394.  
  395. 2) ROM BIOS automatically waits for the cassette motor to reach neccessary
  396.    speed, writes a leader, a syncronization bit and a syncronization byte. It
  397.    then writes the data in your buffer and forces it to take up a multiple of
  398.    256 bytes by appending zeroes. Then a 16-bit number to be used for cyclical
  399.    redundancy checks and a trailer are added to the end of the block.
  400.  
  401.  
  402. INTERRUPT 16 -- Keyboard I/O
  403.  
  404. (AH)    Operation            Also on entry              On return
  405. ------------------------------------------------------------------------------
  406.   0     Wait for keypress                               (AL) = Character read
  407.                                                         (AH) = Scan code of
  408.                                                                character read
  409.                                                                (i.e. if it's
  410.                                                                Ctrl, Shift, Alt,
  411.                                                                or a combination)
  412.  
  413.   1     Check for character                             Zero flag = 1 if buffer
  414.         ready                                           is empty
  415.                                                         Zero flag = 0 if buffer
  416.                                                         is not empty. Next char.
  417.                                                         is in (AL), scan code is
  418.                                                         in (AH)
  419.  
  420.   2     Return shift status                             (AL) = Shift status
  421.  
  422.                                                         [ See note #1 for more
  423.                                                         information ]
  424. ________________________________________________________________________________
  425.  
  426. Notes on interrupt 16:
  427.  
  428. 1) The shift status byte returned by function #2 looks like this:
  429.  
  430.         7 6 5 4 3 2 1 0
  431.  
  432.                 Bit     Meaning (when on)
  433.                  0      Right shift key depressed
  434.                  1      Left shift key is depressed
  435.                  2      Ctrl key depressed
  436.                  3      Alt key depressed
  437.                  4      Scroll Lock state is on
  438.                  5      Num Lock state is on
  439.                  6      Caps Lock state in on
  440.                  7      Insert mode is on
  441.  
  442. 2) The shift status byte is located at memory location 0040:0017, and is called
  443.    KB_FLAG by IBM. At location 0040:0018 is KB_FLAG_1, which looks like the
  444.    following:
  445.  
  446.         7 6 5 4 3 2 1 0
  447.  
  448.                 Bit     Meaning (when on)
  449.                  3      Hold state (Ctrl-Num Lock) is on
  450.                  4      The Scroll Lock key is depressed
  451.                  5      The Num Lock key is depressed
  452.                  6      The Caps Lock key is depressed
  453.                  7      The Insert key is depressed
  454.  
  455.         [ Bits 0, 1, and 2 have no meaning ]
  456.  
  457.  
  458. INTERRUPT 17 -- Printer I/O
  459.  
  460. (AH)    Operation            Also on entry              On return
  461. ------------------------------------------------------------------------------
  462.  
  463.   0     Print a character    (AL) = Character to be     (AH) = Printer status
  464.                                     printed                    byte (see note
  465.                              (DX) = Printer to use             #1)
  466.                                     (0=LPT1, 1=LPT2
  467.                                     2=LPT3)
  468.  
  469.   1     Initialize printer   (DX) = Printer to use      (AH) = Printer status
  470.                                                                byte
  471.  
  472.   2     Read printer status  (DX) = Printer to use      (AH) = Printer status
  473.         byte                                                   byte
  474. ________________________________________________________________________________
  475.  
  476. Notes on interrupt 17:
  477.  
  478. 1) The printer status byte looks like this:
  479.  
  480.         7 6 5 4 3 2 1 0
  481.  
  482.                 Bit     Meaning (when on)
  483.                  0      Time out error
  484.                  3      I/O error
  485.                  4      Selected (off-line)
  486.                  5      Out of paper
  487.                  6      Acknowledge
  488.                  7      Busy
  489.  
  490.         [ Bits 1 and 2 have no meaning ]
  491.  
  492. INTERRUPT 1A -- Time-of-Day
  493.  
  494. (AH)    Operation            Also on entry              On return
  495. ------------------------------------------------------------------------------
  496.  
  497.   0     Read current clock                              (CX) = High 16 bits of
  498.         setting                                                count
  499.                                                         (DX) = Low 16 bits of
  500.                                                                count
  501.                                                         (AL) = 0 if the time was
  502.                                                                last read within
  503.                                                                24 hours.
  504.                                                                Otherwise,
  505.                                                                (AL) = 1
  506.   1     Set the system     (CX) = High 16 bits of count
  507.         clock              (DX) = Low 16 bits of count
  508. ________________________________________________________________________________
  509.  
  510. Notes on interrupt 1A:
  511.  
  512. 1) The count is the amount of 0.05492 (65535/1193100) seconds that have passed
  513.    since 12 a.m. on January 1, 1980. Upon booting/rebooting, the count becomes
  514.    zero (12 a.m.) and the system date becomes January 1, 1980 (although these
  515.    could differ if you have a real-time clock/calendar installed).
  516.  
  517. 2) The count is incremented 18.205 times per second (or, in fractional
  518.    form, 1193100/65536 times per second).
  519.  
  520. 3) After CX and DX both reach 65535 (FFFF hex), they stop increasing. (You don't
  521.    have to worry about this happening, though, unless you leave your computer on
  522.    for seven years -- until the system date reaches December 31, 2099.)
  523.  
  524.  
  525.           SOME INTERESTING INTERRUPTS THAT ONLY HAVE SINGLE FUNCTIONS
  526.  
  527.  
  528. INTERRUPT 5 -- PRINT SCREEN
  529.  
  530.         Interrupt 5 prints everything on your screen.  It is normally activated
  531. when you press <shift><PrtSc>, although it can be called from an assembly
  532. language program with an INT 5 instruction.
  533.  
  534.         Interrupt 5 returns a status byte in memory location 0050:0000.  If this
  535. byte is 0, the screen was successfully printed.  If an error occurred during
  536. printing, this byte is FF (decimal 255).
  537.  
  538. ________________________________________________________________________________
  539.  
  540. INTERRUPT 11 -- EQUIPMENT CHECK
  541.  
  542.         Interrupt 11 reads the word at location 0040:0010, which contains some
  543. information about the system's hardware (taken from the DIP switch settings),
  544. and returns it in AX.  AX then looks like this:
  545.  
  546.         15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
  547.  
  548. Bit  1 -- If on, computer has diskettes. Otherwise, no diskettes.
  549. Bit 12 -- If on, computer has game I/O card. Otherwise, no game I/O card.
  550.  
  551. Bits    Meaning                         How to Read Bits
  552. ----    -------                         ----------------
  553. 2&3     Memory on system board          00 = 16K
  554.                                         01 = 32K
  555.                                         10 = 48K
  556.                                         11 = 64K
  557.  
  558. 4&5     Original video mode             00 = None (could be a T.V. set)
  559.                                         01 = 40x25 B/W, (color/graphics monitor)
  560.                                         10 = 80x25 B/W, (color/graphics monitor)
  561.                                         11 = 80x25 B/W, (monochrome monitor)
  562.  
  563. 6&7     Number of disk drives           00 = 1
  564.         (only valid if bit 1            01 = 2
  565.         is on)                          10 = 3
  566.                                         11 = 4 or more
  567.  
  568. 9&10    Number of RS-232 cards          00 = None
  569.         (serial ports)                  01 = 1
  570.                                         10 = 2
  571.                                         11 = 3
  572.  
  573. 14&15   Number of printers              00 = None
  574.         (parallel ports)                01 = 1
  575.                                         10 = 2
  576.                                         11 = 3
  577.  
  578.  
  579.  
  580. INTERRUPT 18 -- CASSETTE BASIC
  581.  
  582.         An INT 18H instruction causes the computer to enter cassette BASIC,
  583. which is the form of BASIC that you use if you don't have diskettes (or if you
  584. forget to close the disk drive door when you boot up).
  585. ________________________________________________________________________________
  586.  
  587. INTERRUPT 19 -- REBOOT
  588.  
  589.         When you press <CTRL-ALT-DEL>, an interrupt 19 is executed.  When put in
  590. a program, an INT 19H will reboot the system.
  591. ________________________________________________________________________________
  592.  
  593. INTERRUPT 1B -- BREAK
  594.  
  595.         When you press <CTRL-Break>, the computer executes an INT 1BH
  596. instruction, which just performs an IRET instruction and returns to DOS.  The
  597. pointer to this interrupt could be changed if you want to implement your own
  598. <CTRL-Break> handler.
  599. ________________________________________________________________________________
  600.  
  601. INTERRUPT 1C -- TIMER TICK
  602.  
  603.         18.205 times per second, an INT 18H instruction is executed.  Like
  604. interrupt 1B, this interrupt is only an IRET instruction.  If you have a routine
  605. that needs to be called 18.205 times a second, this interrupt could be helpful.
  606.  
  607.  
  608.  
  609. SEND ALL QUESTIONS AND COMMENTS TO:
  610. Scott Pakin
  611. 6007 N. Sheridan Rd.
  612. Chicago, IL    60660
  613.  
  614.  
  615.